package net.borderwars.simulator.events;

import net.borderwars.robots.Factory;
import net.borderwars.robots.VirtualMachine;
import net.borderwars.simulator.BattlePlane;

/**
 * This event represents a new robot being placed into the BattlePlane
 * A factory will place this event in the future when it begins production of a robot
 * It will not have any new cpu cycles until after this event fires
 *
 * @author Eric
 *         Date: Mar 18, 2004
 *         Time: 9:34:58 AM
 */

public class NewRobot extends BEvent {
    private Factory factory = null;
    private BattlePlane bp = null;

    public NewRobot(long l) {
        super(l);
    }

    public void process() {

        VirtualMachine newVm = null;
        //newVm = new VirtualMachine("c:\\data\\borderwars\\classes\\net\\borderwars\\robots\\Test.class", 2000, null);

        // schedule the first clock cycle for the new robot
        CPUCycle c = new CPUCycle(bp.getClock().getCurrentTime() + 100, newVm);
        bp.getEventQueue().placeEvent(c);

        // reschedule the Factory -- its now done building the robot
        CPUCycle fc = new CPUCycle(bp.getClock().getCurrentTime() + 10, factory.getVM());
        bp.getEventQueue().placeEvent(fc);

    }

    public String getName() {
        return ("New Robot");
    }

    public void setProductionFactory(Factory factory) {
        this.factory = factory;

    }

    public void setBattlePlane(BattlePlane bp) {
        this.bp = bp;

    }
}
